package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BizRiderAccount;
import com.ruoyi.system.service.IBizRiderAccountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配送员账户Controller
 * 
 * @author ruoyi
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/riderAccount/account")
public class BizRiderAccountController extends BaseController
{
    @Autowired
    private IBizRiderAccountService bizRiderAccountService;

    /**
     * 查询配送员账户列表
     */
    @PreAuthorize("@ss.hasPermi('riderAccount:account:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizRiderAccount bizRiderAccount)
    {
        startPage();
        List<BizRiderAccount> list = bizRiderAccountService.selectBizRiderAccountList(bizRiderAccount);
        return getDataTable(list);
    }


    /**
     * 导出配送员账户列表
     */
    @PreAuthorize("@ss.hasPermi('riderAccount:account:export')")
    @Log(title = "配送员账户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizRiderAccount bizRiderAccount)
    {
        List<BizRiderAccount> list = bizRiderAccountService.selectBizRiderAccountList(bizRiderAccount);
        ExcelUtil<BizRiderAccount> util = new ExcelUtil<BizRiderAccount>(BizRiderAccount.class);
        util.exportExcel(response, list, "配送员账户数据");
    }

    /**
     * 获取配送员账户详细信息
     */
    @PreAuthorize("@ss.hasPermi('riderAccount:account:query')")
    @GetMapping(value = "/{riderId}")
    public AjaxResult getInfo(@PathVariable("riderId") Integer riderId)
    {
        return success(bizRiderAccountService.selectBizRiderAccountByRiderId(riderId));
    }

    /**
     * 新增配送员账户
     */
    @PreAuthorize("@ss.hasPermi('riderAccount:account:add')")
    @Log(title = "配送员账户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizRiderAccount bizRiderAccount)
    {
        return toAjax(bizRiderAccountService.insertBizRiderAccount(bizRiderAccount));
    }

    /**
     * 修改配送员账户
     */
    @PreAuthorize("@ss.hasPermi('riderAccount:account:edit')")
    @Log(title = "配送员账户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizRiderAccount bizRiderAccount)
    {
        return toAjax(bizRiderAccountService.updateBizRiderAccount(bizRiderAccount));
    }

    /**
     * 删除配送员账户
     */
    @PreAuthorize("@ss.hasPermi('riderAccount:account:remove')")
    @Log(title = "配送员账户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(bizRiderAccountService.deleteBizRiderAccountByIds(ids));
    }
}
